#ifndef MAINWEATHER_H
#define MAINWEATHER_H

#include <QMainWindow>
#include <QMenu>
#include <QAction>
#include <QContextMenuEvent>
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QLabel>
#include <QJsonArray>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonParseError>
class Today
{
public:
    Today() {}
    QString date;
    QString quality;
    QString wendu;
    QString city;
    QString type;
    QString notice;
    QString shidu;
    int pm25;
    QString fx;
    QString fl;
    QString ganmao;
};

class Day
{
public:
    Day() {}
    QString date;
    int aqi;
    QString type;
    QString high;
    QString low;
};

namespace Ui {
//class MainWeather;
class Weather;
}

class MainWeather : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWeather(QWidget *parent = 0);
    ~MainWeather();
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
protected:

private slots:
    void replyHandle(QNetworkReply *reply);
    void on_searchBt_clicked();

private:
    Ui::Weather *ui;
    QMenu *exitMenu;
    QAction *exitAction;
    //鼠标事件偏移量
    QPoint offset;
    //网络请求
    QNetworkAccessManager *networkAccessManager;
    //请求天气数据
    void requestWeather(QString cityCode);
    //右键菜单事件
    void contextMenuEvent(QContextMenuEvent *event);
    //解析json数据
    void parseJson(QByteArray &byteArray);
    //更新ui界面数据
    void updateUi();
    //事件过滤器
    bool eventFilter(QObject *watched, QEvent *event);
    //温度曲线绘图
    void paintTempCurve();
    //温度节点的x坐标盒子
    int xPointArray[6];
    //最高温度节点的y坐标盒子
    int yHighPointArray[6];
    //最低温度节点的y坐标盒子
    int yLowPointArray[6];
    //高温y值数组
    int highYArray[6];
    //低温y值数组
    int lowYArray[6];
    //天气类型资源qmap
    QMap<QString,QString> typeMap;
    //初始化typeMap
    void initIconMap();
    //日期、空气质量、天气类型、最高温、最低温
    QList<QLabel*>dateLbList;
    QList<QLabel*>qualityLbList;
    QList<QLabel*>typeLbList;
    QList<QLabel*>highLbList;
    QList<QLabel*>lowLbList;
    //天气分类图标
    QList<QLabel*>typeIcoLbList;


    Today wToday;
    Day wDays[6];

};

#endif // MAINWEATHER_H
